package org.feidao.chapter65.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
 * Created by linghufeixia on 2022-12-28.
 * fanout config
 */
@Configuration
public class FanoutConfig {
    @Bean("fanout_exchange")
    public FanoutExchange fanoutExchange() {
        return ExchangeBuilder.fanoutExchange("fanout_exchange").durable(true).build();
    }

    @Bean("fanout_queue_A")
    public Queue fanoutQueueA(){
        return QueueBuilder.durable("fanout_queue_A").build();
    }

    @Bean
    public Binding fanoutBindA(){
        return BindingBuilder.bind(fanoutQueueA()).to(fanoutExchange());
    }


    @Bean("fanout_queue_B")
    public Queue fanoutQueueB(){
        return QueueBuilder.durable("fanout_queue_B").build();
    }

    @Bean
    public Binding fanoutBindB(){
        return BindingBuilder.bind(fanoutQueueB()).to(fanoutExchange());
    }
}
